import api from '@/api/index.ts'

// 获取卡券列表
export function GetData(params: any) {
  return api.get('/api/coupon/list', { params })
}
// 获取选项
export function GetOptionData(type?: string) {
  return api.get(`/api/coupon/optionlist${type ? `?type=${type}` : ''}`)
}
// 获取卡券列表
export function GetBgUrl(params: any) {
  return api.get('/api/coupon/getcouponbgpic/list', { params })
}

// 修改领取卡券页面背景
export function PostAlterBgUrl(params: any) {
  return api.post(`/api/coupon/modifygetcouponbgpic`, params)
}

// 添加卡券
export function PostAddCoupon(params: any) {
  return api.post(`/api/coupon/create`, params)
}

// 修改商品排序
export function patchListSort(params: any) {
  return api.post(`/api/coupon/relationproduct/modifysort`, params)
}

// 获取卡券详细数据
export function GetDataDetail(id: string) {
  return api.get(`/api/coupon/detail/${id}`)
}

// 编辑卡券
export function PutCouponModify(params: any) {
  return api.put(`/api/coupon/modify`, params)
}

// 更改卡券状态
export function patchListType(params: any) {
  return api.patch(`/api/coupon/modifystatus`, params)
}

// 删除卡券
export function deleteCoupon(id: number) {
  return api.delete(`/api/coupon/delete/${id}`)
}

// 获取关联商品
export function GetRelationproduct(params: any) {
  // console.log(params)
  return api.get('/api/coupon/relationproduct/list', { params })
}

// 取消关联商品
export function cancelCoupon(data: any) {
  return api.delete(`/api/coupon/relationproduct/delete`, { data })
}

// 关联商品
export function PostRelationproduct(params: any) {
  return api.post(`/api/coupon/relationproduct/create`, params)
}
// 关联商品
export function PostCopy(id: number) {
  return api.post(`/api/coupon/copy/${id}`)
}
// 获取卡券导出数据
export function GetExcelData(params: any) {
  return api.get('/api/coupon/dataexcel', { params, responseType: 'blob' })
}
